package conexaoDAO;


import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Conexao {
    
public static String status = "conexao vasia";
private static final String url= "jdbc:postgresql://localhost:5432/tcc";
private static final String driver = "org.postgresql.Driver";
private static final String usuario = "postgres";
private static final String senha = "nemesis";

public static Connection getConnection(){
    
Connection conn = null;
try{
Class.forName(driver);
conn = DriverManager.getConnection(url, usuario, senha);
status = "conectado";
}
catch (ClassNotFoundException e){
status = e.getMessage();
}
catch(SQLException e){
    status = e.getMessage();
}
catch(Exception e){
    status = e.getMessage();
}
return conn;
}
 public static PreparedStatement getPreparedStatement(String sql) throws SQLException {
        return getConnection().prepareStatement(sql);
}
 public static void close (){
        try {
            Conexao.getConnection().close();
        } catch (SQLException ex) {
            Logger.getLogger(Conexao.class.getName()).log(Level.SEVERE, null, ex);
        }
 }
}
